<template>
  <div>
    <el-row>
      <el-col :span="18">
        <el-card shadow="never">
          <div>
            <Dplayer ref="dplayer" :dplayerData="dplayerData"></Dplayer>
          </div>
          <div>
            <div>
              <el-card shadow="never">
                <el-row>
                  <el-col :span="20">
                    <div class="left_card_div">
                      <div class="left_card_videoTitle">
                        <span>{{ this.videoData[0]['video_title'] }}</span>
                      </div>
                      <div class="left_card_videoView">
                        <span class="el-icon-view">{{ this.videoData[0]['video_view'] }}</span>
                      </div>
                    </div>
                  </el-col>
                  <el-col :span="4">
                    <div>
                      <div style="float: left">
                        <el-avatar>admin</el-avatar>
                      </div>
                      <div >
                        <div style="margin-bottom: 5px">
                          <!--视频作者-->
                          <span style="margin: 5px">林永护</span>
                        </div>
                        <div style="line-height: 10px;font-size: 10px">
                          <span class="el-icon-video-camera">视频提供者</span>
                        </div>
                      </div>
                    </div>
                  </el-col>
                </el-row>
              </el-card>
            </div>
          </div>

          <div class="left_card_div">
            <VideoLike
              :id="this.info.video_id"
              :username="this.username"
            ></VideoLike>
          </div>
          <el-divider></el-divider>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card shadow="never">
          <div v-for="item in allVideoData" :key="item" class="right_card_div">
            <div>
              <el-image :src="item['video_img']" class="right_card_img"></el-image>
            </div>
            <div class="right_card_div">
              <div class="right_card_videoTitle">
                <span>{{ item['video_title'] }}</span>
              </div>
              <div class="right_card_videoView">
                <span class="el-icon-view">{{ item['video_view'] }}</span>
              </div>
              <el-divider></el-divider>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import Dplayer from "../../components/dplayer.vue";
import VideoLike from "../countComponents/videoLike.vue";

export default {
  components: {VideoLike, Dplayer},
  data() {
    return{
      dplayerData: {
        style: 'width:100%;height:500px'
      },
      username:'',
      info:{
        url:'',
        img:'',
        video_id:null,
      },
      videoData:[{
        video_title:'',
        video_view:'',
      }],
      allVideoData:[],
    }
  },
  created() {
    setTimeout(()=>{
      this.switchVideo()
    },500)
  },
  mounted() {
    this.info = this.$route.query
    this.getUser()
    this.getThisVideoData()
    this.getAllVideoData()
  },
  methods: {
    switchVideo(){
      this.$refs.dplayer.switchVideo(this.info)
    },
    getUser() {
      this.username = localStorage.getItem('username')
    },
    // 获取当前视频的标题和播放量
    getThisVideoData() {
      this.$axios.get('api/video/info/',{
        params:{video_id:this.info.video_id}
      }).then((response)=>{
        const res = response.data
        if (res['respCode']==='000000') {
          this.videoData = res['list']
        }else {
          console.log(res['respMsg'])
        }
      })
    },
    getAllVideoData() {
      this.$axios.get('api/video/info/',{
      }).then((response)=>{
        const res = response.data
        if (res['respCode']==='000000') {
          this.allVideoData = res['list']
        }else {
          console.log(res['respMsg'])
        }
      })
    },
  }
}

</script>

<style scoped>
.right_card_img {
  float: left;
  width: 100px;
  height: 100px;
  margin-right: 5px;
}
.right_card_videoTitle{
  font-size: 20px;
  margin-bottom: 20px;
  height: 60px;
  word-wrap: break-word;
  overflow: hidden;
  font-family: "lucida grande", "lucida sans unicode", lucida, helvetica, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;

}
.left_card_videoTitle {
  margin-bottom: 10px;
  font-size: 28px;
  font-family: "lucida grande", "lucida sans unicode", lucida, helvetica, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
}
.right_card_videoView {
  font-size: 12px;
  line-height: 12px;
}
.left_card_videoView {
  font-size: 15px;
  line-height: 15px;
}
.right_card_div {
  height: 110px;
  margin-bottom: 10px;
}
.el-divider {
  margin-top: 20px;
}
.left_card_div {
  margin: 10px;
  width: 100%;
}
</style>
